package maths

import (
	"fmt"
	"math"
	"strconv"
)

func StandardDeviationPopulation(input Float64Data) (sdev float64, err error) {

	if input.Len() == 0 {
		return math.NaN(), EmptyInputErr
	}

	vp, _ := PopulationVariance(input)

	return math.Pow(vp, 0.5), nil
}

func DivideInt64(a, b int64) float64 {
	if b == 0 {
		return 0
	}
	return float64(a) / float64(b)
}

func DivideFloat64(a, b float64) float64 {
	if b == 0 {
		return 0
	}
	return a / b
}

func ToFloat64_b2(v float64) float64 {
	f, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", v), 64)
	return f
}
